***************************************************************************************************
***************************************************************************************************
**************

***************************************************************************************************
** Set the working directory
*cd "C:\~"


use "DataFile_ReplicationMaterialsISQ_14Dec2021.dta"

eststo clear

eststo: xtnbreg f.ProtestsRiots_count  C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex ///                  
				   H1_PublicInfoCampaigns StateRepression_count ///
				  deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe
				  
				  
gen regression_sample=_est_est1


estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace
					 
estimates store FElogit_COVID



eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex c.C2_WorkplaceClosin#c.economicsupportindex ///                  
										H1_PublicInfoCampaigns StateRepression_count ///
										deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

estimates store FElogit_COVID_Int	

margins ,  at(C1_SchoolClosing=(0(1)3))  atmeans 
						 						 
marginsplot, level(95) xlabel(0 "0" 1 "1" 2 "2" 3 "3", angle(0) labsize(small)) ///
						xtitle("", size(small)) ytitle("Linear Prediction", size(small))  ///
						plot1opts(msymbol(O) mcolor(black) msize(small)) ///
						 plot( , label("Concession" "Repression"))  aspectratio(1.2) ///
						 recast(scatter) ciopts(lwidth(medthin))   yline(0,lcolor(navy) lpattern(l) lwidth(medthin) ) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white))  ///
 addplot(hist C1_SchoolClosing, percent scheme(burd) discret width(.5) yaxis(2) ///
 ytitle("% obs. at policy level", axis(2) size(small)) yscale(alt axis(2)) fcolor(none) lc(black) legend( pos(6) order(0 "" )) )  ///
   title("4b: School Closures", size(small)) saving("Figures/C1_SchoolClosing.gph", replace) 	

 gr export "Figures/C1_SchoolClosing.png", replace width(4000)

***

margins ,  at(C2_WorkplaceClosing=(0(1)3)) atmeans 
						 						 
marginsplot, level(95) xlabel(0 "0" 1 "1" 2 "2" 3 "3", angle(0) labsize(small)) ///
						xtitle("", size(small)) ytitle("Linear Prediction", size(small))  ///
						plot1opts(msymbol(O) mcolor(black) msize(small)) ///
						 plot( , label("Concession" "Repression"))  aspectratio(1.2) ///
						 recast(scatter) ciopts(lwidth(medthin))   yline(0,lcolor(navy) lpattern(l) lwidth(medthin) ) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white))  ///
 addplot(hist C2_WorkplaceClosing, percent scheme(burd) discret width(.5) yaxis(2) ///
 ytitle("% obs. at policy level", axis(2) size(small)) yscale(alt axis(2)) fcolor(none) lc(black) legend( pos(6) order(0 "" )) )  ///
   title("4a: Workplace Closures", size(small)) saving("Figures/C2_WorkplaceClosing.gph", replace) 
						  
gr export "Figures/C2_WorkplaceClosing.png", replace width(4000)

****

margins ,  at(economicsupportindex=(0(1)10))  atmeans 
						 						 
marginsplot, level(95) xlabel(  , angle(0) labsize(small)) ///
						xtitle("Economic Support Index", size(small)) ytitle("Linear Prediction", size(small))   ///
						plot1opts(msymbol(O) mcolor(black) msize(small)) ///
						 plot( , label("Concession" "Repression"))  aspectratio(1.2) ///
						 recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin))  ///
						  plotregion(fcolor(white)) graphregion(fcolor(white))  /// 
 addplot(hist economicsupportindex, percent scheme(burd)  width(1.25) yaxis(2) xlabel(, angle(0) labsize(small)) ///
	ytitle("% obs. at policy level", axis(2) size(small)) yscale(alt axis(2)) fcolor(none) lc(black) legend( pos(6) order(0 "" )) )  ///
   title("") saving("Figures/economicsupportindex.gph", replace)  scheme(lean1)
						  
						
gr export "Figures/economicsupportindex.png", replace width(4000)


***

margins ,  at(C4_RestrictionsGatherings=(0(1)4)) atmeans 
						 						 
						 						 
marginsplot, level(95) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" , angle(0) labsize(small)) ///
						xtitle("", size(small)) ytitle("Linear Prediction", size(small))   ///
						plot1opts(msymbol(O) mcolor(black) msize(small)) ///
						  plot( , label("Concession" "Repression") )  aspectratio(1.2) ///
						 recast(scatter) ciopts(lwidth(medthin))   yline(0,lcolor(navy) lpattern(l) lwidth(medthin) ) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white))  /// 
 addplot(hist C4_RestrictionsGatherings, percent scheme(burd) discret width(.5) yaxis(2) ///
	ytitle("% obs. at policy level", axis(2) size(small)) yscale(alt axis(2)) fcolor(none) lc(black) legend( pos(6) order(0 "" )) )  ///
   title("4e: Restrictions on Gatherings", size(small)) saving("Figures/C4_RestrictionsGatherings.gph", replace) 
						  
gr export "Figures/C4_RestrictionsGatherings.png", replace width(4000)
****


margins ,  at(C5_ClosePublicTransport=(0(1)2)) atmeans 
						 						 
						 						 
marginsplot, level(95) xlabel(0 "0" 1 "1" 2 "2", angle(0) labsize(small)) ///
						xtitle("", size(small)) ytitle("Linear Prediction", size(small))   ///
						plot1opts(msymbol(O) mcolor(black) msize(small)) ///
						 plot( , label("Concession" "Repression") )  aspectratio(1.2) ///
						 recast(scatter) ciopts(lwidth(medthin))   yline(0,lcolor(navy) lpattern(l) lwidth(medthin) ) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white))  ///
 addplot(hist C5_ClosePublicTransport, percent scheme(burd) discret width(.5) yaxis(2) ///
 ytitle("% obs. at policy level", axis(2) size(small)) yscale(alt axis(2)) fcolor(none) lc(black) legend( pos(6) order(0 "" )) )  ///
   title("4f: Restrictions on Public Transportation", size(small)) saving("Figures/C5_ClosePublicTransport.gph", replace)
						  
gr export "Figures/C5_ClosePublicTransport.png", replace width(4000)


***

margins ,  at(C7_RestricInternalMovement=(0(1)2))  atmeans 
						 						 
						 						 
marginsplot, level(95) xlabel(0 "0" 1 "1" 2 "2", angle(0) labsize(small)) ///
						xtitle("", size(small)) ytitle("Linear Prediction", size(small))   ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						   plot( , label("Concession" "Repression"))  aspectratio(1.2) ///
						 recast(scatter) ciopts(lwidth(medthin))   yline(0,lcolor(navy) lpattern(l) lwidth(medthin) ) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white))  ///
 addplot(hist C7_RestricInternalMovement, percent scheme(burd) discret width(.5) yaxis(2) xlabel(0 "0" 1 "1" 2 "2", angle(0) labsize(medlarge)) ///
	ytitle("% obs. at policy level", axis(2) size(small)) yscale(alt axis(2)) fcolor(none) lc(black) legend(  order(0 "" )) )  ///
   title("4c: Restrictions on Internal Movement", size(small)) saving("Figures/C7_RestricInternalMovement.gph", replace) 
						  
gr export "Figures/C7_RestricInternalMovement.png", replace width(4000)

*****


margins ,  at(C8_InternatioTravelControl=(0(1)4))  atmeans 
						 						 
						 						 
marginsplot, level(95) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" , angle(0) labsize(small)) ///
						xtitle("", size(small)) ytitle("Linear Prediction", size(small))   ///
						plot1opts(msymbol(O) mcolor(black) msize(small)) ///
						  plot( , label("Concession" "Repression"))  aspectratio(1.2) ///
						 recast(scatter) ciopts(lwidth(medthin))   yline(0,lcolor(navy) lpattern(l) lwidth(medthin) ) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white))  /// 
 addplot(hist C8_InternatioTravelControl, percent scheme(burd) discret width(.5) yaxis(2) ///
	ytitle("% obs. at policy level", axis(2) size(small)) yscale(alt axis(2)) fcolor(none) lc(black) legend( pos(6) order(0 "" )) )  ///
   title("4d: Restrictions on Int. Travel", size(small)) saving("Figures/C8_InternatioTravelControl.gph", replace) 
						  
gr export "Figures/C8_InternatioTravelControl.png", replace width(4000)



gr combine "Figures/C2_WorkplaceClosing.gph" "Figures/C1_SchoolClosing.gph"  /// 
			"Figures/C7_RestricInternalMovement.gph" "Figures/C8_InternatioTravelControl.gph" ///
			"Figures/C4_RestrictionsGatherings.gph"	"Figures/C5_ClosePublicTransport.gph",   ///
			col(2)   plotregion(fcolor(white)) graphregion(fcolor(white))  plotregion(margin(0 -1 -1 0)) ///
			imargin(b=0 t=0) saving("Figures/MarginsPlot_combined_new.gph", replace) 

** Figure 4 in the article
gr export "Figures/MarginsPlot_combined.png", replace width(4000)			

*************************************

***Figure 5 in the article
margins , dydx(C2_WorkplaceClosing) at(economicsupportindex=(0(1)10)) pred(iru0) atmeans


marginsplot, level(95) by()  xlabel(, angle(0) labsize(medlarge)) ///
						xtitle("Economic Support Index") ytitle("Marginal effect of  workplace closures") ///
						plot1opts(msymbol(O) mcolor(black) msize(1.75) ) ///
						title("Marginal effect of workplace closing conditional on income support", size(medsmall)) ///
						   ///
						 recast(line) ciopts(lwidth(medthick) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin))  ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist economicsupportindex, percent scheme(burd) discret width(1.25) yaxis(2) xlabel(, angle(0) labsize(medlarge)) ///
						 ytitle("% obs. at policy level", axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("") saving("Figures/Margins_Income_WorkplaceClosing.gph", replace) 
						  
						 
gr export "Figures/Margins_Income_WorkplaceClosing.png", replace width(4000)


**** Table A2
	
esttab using "Tables\Tbl_MainTable.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g ll bic locationFE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "Log-likelihood" "BIC" "Location FE" "Time FE")) ///
		nobaselevels interaction("X") noomitted label ///
		drop(*.Week) ///
		compress nogap	star(** 0.05 *** 0.01)  ///
		b(%5.3f)  ///
		coeflabels(_cons "Intercept"  ///
					)	
					
********************************************************************************************************************

*** Coef plots

** Figure 3 in the article

coefplot (FElogit_COVID, msymbol(D) mcolor(black) label(Baseline model)) ///
		 (FElogit_COVID_Int, msymbol(S) mcolor(black) label(Interaction model)) ///
		 , drop(_cons *.Month *.Week) xline(0) scheme(lean2) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
		   legend(position(6) row(1))   ///
		   levels(99 95) ciopts(lwidth(1.3 ..) lcolor(*.2 *1) )  ///
		  title("Social unrest and COVID policies") saving("Figures/CoefPlots_Combined_1.gph", replace)

		  		  
gr export "Figures/CoefPlots_Combined_1_new.png", replace width(4000)


*************************************************************************************************************************************************************
*************************************************************************************************************************************************************

********************************************************************* Appendix ******************************************************************************

*************************************************************************************************************************************************************
*************************************************************************************************************************************************************


 set matsize 11000

 ** Table A1 in the appendix
qui outreg2 using "Tables\SummaryTable_appendix.doc" if regression_sample==1, replace sum(log) ///
			keep(ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex E1_IncomeSupport E2_DebtContractRelief ///                  
										H1_PublicInfoCampaigns StateRepression_count ///
										deaths_week_capita_log)


*** Multicolinearity test


reg f.ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex ///                  
										H1_PublicInfoCampaigns StateRepression_count ///
				  deaths_week_capita_log   if regression_sample==1

**Table A11 in the appendix
vif

********** corelation matrix

*ssc install asdoc						  
**Table A10 in the appendix
asdoc cor        C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex ///                  
				   H1_PublicInfoCampaigns StateRepression_count ///
				  deaths_week_capita_log  if regression_sample==1  , label replace 

							
*****************

***** Robustness check *******

eststo clear


eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin##c.polity2 C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

				  
				  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace
					 
*estimates store FElogit_COVID_noDemoc


margins , dydx(C2_WorkplaceClosin) at(polity2=(-10(1)10)) atmeans



marginsplot, level(95)  by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small)  ) ///
						title("Marginal effect of workplace closing conditional on income support", size(medsmall)) ///
						plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						  recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white))  ///
						 addplot(hist polity2, percent scheme(burd) discret width(1) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Workplace Closures", size(small)) saving("Figures/Margins_Polity_SchoolClosing.gph", replace) 
						  
						 
gr export "Figures/Margins_Polity_WorkplaceClosin.png", replace width(4000)

*****

eststo: xtnbreg f.ProtestsRiots_count  C2_WorkplaceClosin c.C1_SchoolClosing##c.polity2 ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

									  
									  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace

*estimates store FElogit_COVID_Int_noDemoc		

margins , dydx(C1_SchoolClosing) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						title("Marginal effect of workplace closing conditional on income support", size(medsmall)) ///
						 plot( , label("Concession" "Repression"))  aspectratio(.9)   ///
						  recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(*1)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("School Closures", size(small)) saving("Figures/Margins_Polity_WorkplaceClosing.gph", replace) 
			
gr export "Figures/Margins_Polity_SchoolClosing.png", replace width(4000)


eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   c.C4_RestrictionsGatherings##c.polity2  C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

									  
									  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace
					 
*estimates store FElogit_COVID_SemiDemoc

margins , dydx(C4_RestrictionsGatherings) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						title("Marginal effect of workplace closing conditional on income support", size(medsmall)) ///
						 plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						  recast(line) ciopts(lwidth(medthick) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Restrictions on Gathering", size(small)) saving("Figures/Margins_Polity_RestrictionsGatherings.gph", replace) 
			
gr export "Figures/Margins_Polity_RestrictionsGatherings.png", replace width(4000)



eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings  C6_StayHomeRequirements c.C5_ClosePublicTransport##c.polity2 ///
										economicsupportindex H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

									  
									  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace

*estimates store FElogit_COVID_Int_SemiDemoc	

margins , dydx(C5_ClosePublicTransport) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						  plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						 recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Closing Public Transport", size(small)) saving("Figures/Margins_Polity_ClosePublicTransport.gph", replace) 
			
gr export "Figures/Margins_Polity_ClosePublicTransport.png", replace width(4000)


eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings  c.C6_StayHomeRequirements##c.polity2 c.C5_ClosePublicTransport ///
										economicsupportindex H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

									  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace
					 
*estimates store FElogit_COVID_Democ

margins , dydx(C6_StayHomeRequirements) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						  plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						 recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Stay Home Requirements", size(small)) saving("Figures/Margins_Polity_StayHomeRequirements.gph", replace) 
			
gr export "Figures/Margins_Polity_StayHomeRequirements.png", replace width(4000)


eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin C1_SchoolClosing ///
									   c.C7_RestricInternalMovement##c.polity2  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings  c.C6_StayHomeRequirements c.C5_ClosePublicTransport ///
										economicsupportindex H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

									  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace

*estimates store FElogit_COVID_Int_Democ		

margins , dydx(C7_RestricInternalMovement) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						  plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						  recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)  yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Restrictions on Internal Movement", size(small)) saving("Figures/Margins_Polity_RestricInternalMovement.gph", replace) 
			
gr export "Figures/Margins_Polity_RestricInternalMovement.png", replace width(4000)


eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin C1_SchoolClosing ///
									   c.C7_RestricInternalMovement  c.C8_InternatioTravelControl##c.polity2 ///
									   C4_RestrictionsGatherings  c.C6_StayHomeRequirements c.C5_ClosePublicTransport ///
										economicsupportindex H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

									  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace

*estimates store FElogit_COVID_Int_Democ	

margins , dydx(C8_InternatioTravelControl) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						  plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						 recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Restrictions on Int. Travel", size(small)) saving("Figures/Margins_Polity_InternatioTravelControl.gph", replace) 
			
gr export "Figures/Margins_Polity_InternatioTravelControl.png", replace width(4000)



eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin C1_SchoolClosing ///
									   c.C7_RestricInternalMovement  c.C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings  c.C6_StayHomeRequirements c.C5_ClosePublicTransport ///
										c.economicsupportindex##c.polity2 H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace

*estimates store FElogit_COVID_Int_Democ	

margins , dydx(economicsupportindex) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						  plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						 recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Economic Support Index", size(small)) saving("Figures/Margins_Polity_economicsupportindex.gph", replace) 
			
gr export "Figures/Margins_Polity_economicsupportindex.png", replace width(4000)


eststo: xtnbreg f.ProtestsRiots_count  c.C2_WorkplaceClosin C1_SchoolClosing ///
									   c.C7_RestricInternalMovement  c.C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings  c.C6_StayHomeRequirements c.C5_ClosePublicTransport ///
										c.economicsupportindex c.H1_PublicInfoCampaigns##c.polity2 ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log i.Week ///
									  if deaths_cum > 0 & deaths_cum != . , re

									  
estadd local locationRE      "Country" , replace
estadd local timeFE          "Week" , replace

*estimates store FElogit_COVID_Int_Democ	

margins , dydx(H1_PublicInfoCampaigns) at(polity2=(-10(1)10)) atmeans


marginsplot, level(95) by()  xlabel(-10(2)10, angle(0) labsize(small)) ///
						xtitle("Polity", size(small)) ytitle("Effects on Linear Prediction", size(small)) ///
						plot1opts(msymbol(O) mcolor(black) msize(small) ) ///
						  plot( , label("Concession" "Repression"))  aspectratio(.9) ///
						 recast(line) ciopts(lwidth(medthin) color(blue) lpattern(dash))  recastci(rline)   yline(0,lcolor(navy) lpattern(l) lwidth(medthin)) ///
						 scheme(lean1) plotregion(fcolor(white)) graphregion(fcolor(white)) ///
						 addplot(hist polity2, percent scheme(burd) discret width(.5) yaxis(2) xlabel(-10(2)10, angle(0) labsize(small)) ///
						 ytitle("% Obs. at polity level", size(small) axis(2)) ///
						  yscale(alt axis(2)) fcolor(none) lc(black) legend( order(0 "" )) )  ///
                         title("Public Information Campaigns", size(small)) saving("Figures/Margins_Polity_PublicInfoCampaigns.gph", replace) 
			
gr export "Figures/Margins_Polity_PublicInfoCampaigns.png", replace width(4000)


** Table A9 in the appendix
esttab using "Tables\App_Tbl_MainTableDemocracy.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g r2 locationRE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "R-squared" "Location RE" "Time FE")) ///
		nobaselevels interaction("X") noomitted label ///
		drop(*.Week) ///
		compress nogap	star(+ .1 ** 0.05 *** 0.01)  ///
		b(%5.2f)  ///
		coeflabels(_cons "Intercept"  ///
					)	
					
*Figure A1 in the appendix				
gr combine  "Figures/Margins_Polity_SchoolClosing.gph" "Figures/Margins_Polity_WorkplaceClosing.gph" ///
            "Figures/Margins_Polity_RestrictionsGatherings.gph" "Figures/Margins_Polity_ClosePublicTransport.gph" ///
			"Figures/Margins_Polity_StayHomeRequirements.gph" "Figures/Margins_Polity_RestricInternalMovement.gph" ///
			"Figures/Margins_Polity_InternatioTravelControl.gph" "Figures/Margins_Polity_economicsupportindex.gph" ///
			"Figures/Margins_Polity_PublicInfoCampaigns.gph", ///
	         graphregion(margin(t=-1 b=-1 l=-2 r=-1)) plotregion(margin(t=0 b=0 l=1 r=-5)) imargin(t=-4 b=-5 l=-2 r=-7)  col(3)  scheme(lean1) xsize(18) ysize(10) iscale(*1.05) ///
			 saving("Figures/Comined_Margins_polity_interactions.gph", replace) 

	gr export "Figures/Comined_Margins_polity_interactions.png", replace width(4000)		 
***********************************************************

*** Debt relief and income support

eststo clear


eststo: xtnbreg f.ProtestsRiots_count  C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
									   E1_IncomeSupport H1_PublicInfoCampaigns  ///
				                       StateRepression_count deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe


estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace




eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										E1_IncomeSupport c.C2_WorkplaceClosin#c.E1_IncomeSupport ///                  
										H1_PublicInfoCampaigns StateRepression_count ///
										StateRepression_count deaths_week_capita_log  i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace


eststo: xtnbreg f.ProtestsRiots_count  C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										E2_DebtContractRelief  H1_PublicInfoCampaigns  ///
										StateRepression_count deaths_week_capita_log  i.Week if deaths_cum > 0 & deaths_cum != ., fe


estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace



eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										E2_DebtContractRelief c.C2_WorkplaceClosin#c.E2_DebtContractRelief ///                  
										H1_PublicInfoCampaigns StateRepression_count ///
										StateRepression_count deaths_week_capita_log  i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace


eststo: xtnbreg f.ProtestsRiots_count  C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										E1_IncomeSupport E2_DebtContractRelief  H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log  i.Week if deaths_cum > 0 & deaths_cum != ., fe


estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace




eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										E1_IncomeSupport E2_DebtContractRelief c.C2_WorkplaceClosin#c.E1_IncomeSupport c.C2_WorkplaceClosin#c.E2_DebtContractRelief ///                  
										H1_PublicInfoCampaigns  ///
										StateRepression_count deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

	 
** Table A4 in the appendix
esttab using "Tables\App_Tbl_DebtReliefIncomeSupport.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g ll bic locationFE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "Log-likelihood" "BIC" "Location FE" "Time FE")) ///
		nobaselevels interaction("X") noomitted label ///
		drop(*.Week) ///
		compress nogap	star(+ .1 ** 0.05 *** 0.01)  ///
		b(%5.2f)  ///
		coeflabels(_cons "Intercept"  ///
					)			
					
************ ZINB

eststo clear

gen protest_riots_count_forward=f.ProtestsRiots_count

eststo:  zinb protest_riots_count_forward C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
									   economicsupportindex H1_PublicInfoCampaigns ///
									   StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log polity2 i.Week if deaths_cum > 0 & deaths_cum !=., ///
								inflate(C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex  H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log polity2) r 


estadd local timeFE          "Week" , replace


eststo:  zinb protest_riots_count_forward C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
									   economicsupportindex c.C2_WorkplaceClosin#c.economicsupportindex H1_PublicInfoCampaigns ///
									   StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log polity2 i.Week if deaths_cum > 0 & deaths_cum !=., ///
								inflate(C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex  H1_PublicInfoCampaigns ///
										StateRepression_count deaths_week_capita_log pop_log rgdpe_capita_log polity2) r


estadd local timeFE          "Week" , replace


*** Table A7 in the appendix
esttab using "Tables\App_Tbl_ZINB.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g ll bic locationFE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "Log-likelihood" "BIC" "Location FE" "Time FE")) ///
		nobaselevels interaction("X") noomitted label ///
		drop(*.Week) ///
		compress nogap	star(+ .1 ** 0.05 *** 0.01)  ///
		b(%5.2f)  ///
		coeflabels(_cons "Intercept"  ///
					)	
					
*************************************************************

eststo clear


eststo: xtpoisson f.ProtestsRiots_count  C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex ///                  
				   H1_PublicInfoCampaigns StateRepression_count ///
				  deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe
				  
				  


estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace
					 
estimates store FElogit_COVID



eststo: xtpoisson f.ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C4_RestrictionsGatherings C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex c.C2_WorkplaceClosin#c.economicsupportindex ///                  
										H1_PublicInfoCampaigns StateRepression_count ///
										deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

estimates store FElogit_COVID_Int	

** Table A8 in the appendix
esttab using "Tbl_MainTable_xtpoisson.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g ll bic locationFE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "Log-likelihood" "BIC" "Location FE" "Time FE")) ///
		label ///
		drop(*.Week) ///
		compress nogap	star(** 0.05 *** 0.01)  ///
		b(%5.3f)  ///
		coeflabels(_cons "Intercept"  ///
					)	

					
***************************************************************************************
***************************************************************************************
********** Analysis with  cancel public events and public awareness campaigns.

eststo clear

eststo: xtnbreg f.ProtestsRiots_count  C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									    C3_CancelPublicEvents C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex ///                  
										H1_PublicInfoCampaigns  StateRepression_count ///
				  deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe


estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace
					 
estimates store FElogit_COVID



eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin C1_SchoolClosing ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C3_CancelPublicEvents C6_StayHomeRequirements C5_ClosePublicTransport ///
										economicsupportindex c.C2_WorkplaceClosin#c.economicsupportindex ///                  
										H1_PublicInfoCampaigns  StateRepression_count ///
										deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

estimates store FElogit_COVID_Int	

** Table A5 in the appendix
esttab using "Tables\App_Tbl_CancelPublicEvents.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g ll bic locationFE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "Log-likelihood" "BIC" "Location FE" "Time FE")) ///
		nobaselevels interaction("X") noomitted label ///
		drop(*.Week) ///
		compress nogap	star(+ .1 ** 0.05 *** 0.01)  ///
		b(%5.2f)  ///
		coeflabels(_cons "Intercept"  ///
					)	


***************************************************************************************
***************************************************************************************
********** Analysis with  stringencyindex.


eststo clear

eststo: xtnbreg f.ProtestsRiots_count  stringencyindex StateRepression_count ///
				  deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe


estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace


eststo: xtnbreg f.ProtestsRiots_count  c.stringencyindex##c.economicsupportindex StateRepression_count ///
				  deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

** Table A3 in the appendix
esttab using "Tables\App_Tbl_stringencyindex.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g ll bic locationFE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "Log-likelihood" "BIC" "Location FE" "Time FE")) ///
		nobaselevels interaction("X") noomitted label ///
		drop(*.Week) ///
		compress nogap	star(+ .1 ** 0.05 *** 0.01)  ///
		b(%5.2f)  ///
		coeflabels(_cons "Intercept"  ///
					)	


*****************************************************************************************************
*** Interaction of economic support index with policies, other than workplace closure ********
*******************************************************************************************************

eststo clear

eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin c.C1_SchoolClosing##c.economicsupportindex  ///
									   C7_RestricInternalMovement  C8_InternatioTravelControl ///
									   C3_CancelPublicEvents C6_StayHomeRequirements C5_ClosePublicTransport ///
										///                  
										H1_PublicInfoCampaigns  StateRepression_count ///
										deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe technique(dfp)

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin c.C1_SchoolClosing  ///
									   c.C7_RestricInternalMovement##c.economicsupportindex  C8_InternatioTravelControl ///
									   C3_CancelPublicEvents C6_StayHomeRequirements C5_ClosePublicTransport ///
										///                  
										H1_PublicInfoCampaigns  StateRepression_count ///
										deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin c.C1_SchoolClosing  ///
									   C7_RestricInternalMovement  c.C8_InternatioTravelControl##c.economicsupportindex ///
									   C3_CancelPublicEvents C6_StayHomeRequirements C5_ClosePublicTransport ///
										///                  
										H1_PublicInfoCampaigns  StateRepression_count ///
										deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace


eststo: xtnbreg f.ProtestsRiots_count C2_WorkplaceClosin c.C1_SchoolClosing  ///
									   C7_RestricInternalMovement  c.C8_InternatioTravelControl ///
									   C3_CancelPublicEvents c.C6_StayHomeRequirements##c.economicsupportindex C5_ClosePublicTransport ///
										///                  
										H1_PublicInfoCampaigns  StateRepression_count ///
										deaths_week_capita_log i.Week if deaths_cum > 0 & deaths_cum != ., fe

				  
estadd local locationFE      "Country" , replace
estadd local timeFE          "Week" , replace

** Table A6 in the appendix
esttab using "Tables\App_Tbl_EconomicSupporIndex.rtf", replace se varwidth(25) ///
		title(Table 1: Estimation results) ///
		s(N N_g ll bic locationFE timeFE, fmt(%10.2f) ///
		label("N" "Number of groups" "Log-likelihood" "BIC" "Location FE" "Time FE")) ///
		nobaselevels interaction("X") noomitted label ///
		drop(*.Week) ///
		compress nogap	star(+ .1 ** 0.05 *** 0.01)  ///
		b(%5.2f)  ///
		coeflabels(_cons "Intercept"  ///
					)	

***************************************************************

*********** Plots

***************************

gen ProtestsRiots_count_log=log10(1+ProtestsRiots_count)

**Figure A2
twoway (tsline C1_SchoolClosing, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "School Closures" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_C1_SchoolClosing.gpg", replace)   
 
gr export "Figures/LinePlots_C1_SchoolClosing.png", replace width(4000)


**Figure A3
twoway (tsline C2_WorkplaceClosing, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Workplace Closures" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_C2_WorkplaceClosing.gpg", replace)   
 
gr export "Figures/LinePlots_C2_WorkplaceClosing.png", replace width(4000)

** Figure A4
twoway (tsline C4_RestrictionsGatherings, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Restrictions on Gatherings" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_C4_RestrictionsGatherings.gpg", replace)   
 
gr export "Figures/LinePlots_C4_RestrictionsGatherings.png", replace width(4000)


** Figure A5
twoway (tsline C5_ClosePublicTransport, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Restrictions on Public Transportation" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_C5_ClosePublicTransport.gpg", replace)   
 
gr export "Figures/LinePlots_C5_ClosePublicTransport.png", replace width(4000)

** Figure A6
twoway (tsline C6_StayHomeRequirements, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Stay at Home Orders" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_C6_StayHomeRequirements.gpg", replace)   
 
gr export "Figures/LinePlots_C6_StayHomeRequirements.png", replace width(4000)

** Figure A7
twoway (tsline C7_RestricInternalMovement, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Restrictions on Internal Movement" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_C7_RestricInternalMovement.gpg", replace)   
 
gr export "Figures/LinePlots_C7_RestricInternalMovement.png", replace width(4000)

**Figure A8
twoway (tsline C8_InternatioTravelControl, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Restrictions on Int. Travel" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_C8_InternatioTravelControl.gpg", replace)   
 
gr export "Figures/LinePlots_C8_InternatioTravelControl.png", replace width(4000)

**Figure A9
twoway (tsline E1_IncomeSupport, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Income Support" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_E1_IncomeSupport.gpg", replace)   
 
gr export "Figures/LinePlots_E1_IncomeSupport.png", replace width(4000)

**Figure A10
twoway (tsline E2_DebtContractRelief, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Debt Contract Relief" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_E1_IncomeSupport.gpg", replace)   
 
gr export "Figures/LinePlots_E2_DebtContractRelief.png", replace width(4000)

** Figure A11
twoway (tsline economicsupportindex, lwidth(medthick)) (tsline ProtestsRiots_count_log, lwidth(medthick) lpattern(dash)  yaxis(2) ytitle("Social Unrest Count", axis(2)) )  if ///
 country=="Tunisia" | country=="Israel" | country=="Pakistan" | country=="Mexico"| country=="South Africa" | country=="United Kingdom" , ///
 by(country, note("")) tlabel(, angle(vertical)) scheme(burd) legend(col(2)) xtitle("") legend(order(1 "Income Support Index" 2 "Social Unrest")) ///
 saving("Figures/LinePlots_economicsupportindex.gpg", replace)   
 
gr export "Figures/LinePlots_economicsupportindex.png", replace width(4000)


*****************************************************************	

use "OxfordCoronaResponse_WeeklyMonitor.dta", clear

** Economic support is a continious variable, so does not fit wll with other variables. Therefore, 
* it is replaced with income support and debt relief which are two main component of economic support

gen PolicyAvg= (C1_SchoolClosing+C2_WorkplaceClosing+C3_CancelPublicEvents+ ///
			C4_RestrictionsGatherings+C5_ClosePublicTransport+C6_StayHomeRequirements+ ///
			C7_RestricInternalMovement+C8_InternatioTravelControl+E1_IncomeSupport+E2_DebtContractRelief)/10

keep if year==2020

collapse (mean)		PolicyAvg,  by(countryname ISOcode ccode)		
			
save OxfordCoronaResponse_PolicyAverages.dta, replace

***Visual presentation of spatial data

shp2dta using "RawData\gadm28_adm0", ///
 database(WorldMap) coordinates(coor) genid(id) gencentroids(centroid) replace

 
 **** Replace PolicySum by zero if the the country is not in the ACLED COVID dataset

use ACLED_AllCovidEvents.dta, clear

keep if YEAR==2020

collapse (count) INTERACTION , by(country) 
qui do "https://raw.githubusercontent.com/babakrezaee/DataAndCodes/master/CountryToCcode.do"
drop if ccode==.

save ACLED_AllCovidEvents_ToRemoveCountriesNotCovered.dta, replace
 
 
**********************
use WorldMap, clear

rename ISO ISOcode

qui do "https://raw.githubusercontent.com/babakrezaee/DataAndCodes/master/IsoCountryToCcode.do"

joinby ISOcode using "OxfordCoronaResponse_PolicyAverages.dta", unmatched(master)
drop _merge

joinby ccode using "ACLED_AllCovidEvents_ToRemoveCountriesNotCovered.dta", unmatched(master)

replace PolicyAvg=. if INTERACTION==.

format PolicyAvg %12.2f

*
spmap PolicyAvg using coor, id(id)  fcolor(Oranges) ocolor(black ..) osize(thin ..) ///
 legtitle("The average severity COVID-19 policies")  clmethod(quantile) ///
 legend(position(9) region(lstyle(solid) lcolor(white) fcolor(white)) ) 

*graph export "Figures/COVIDPolicy.png", replace width(4000)
graph export "Figures/COVIDPolicy.tif", replace width(864)  
*graph export "Figures/COVIDPolicy.pdf", replace


*
spmap INTERACTION using coor, id(id)  fcolor(Blues) ocolor(black ..) osize(thin ..) ///
 legtitle("The count of COVID related social unrest")  clmethod(quantile) ///
 legend(position(9) region(lstyle(solid) lcolor(white) fcolor(white)) ) 

*graph export "Figures/COVIDevents.png", replace width(4000)
graph export "Figures/COVIDevents.tif", replace width(864) 
*graph export "Figures/COVIDevents.pdf", replace

